package com.sky.service.common;

import com.sky.properties.AliOssProperties;
import com.sky.result.Result;
import com.sky.service.CommonService;
import com.sky.utils.AliOssUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.UUID;

/**
 * 阿里云上传图片
 */
@Service
public class CommonServiceImpl implements CommonService {
     @Resource
    AliOssUtil aliOssUtil;
    @Override
    public Result<String> insertUpload(byte[] bytes,String s) {
        String substring = s.substring((s.lastIndexOf(".")));
        s = UUID.randomUUID().toString().replaceAll("-", "").concat(substring);
        String upload = aliOssUtil.upload(bytes,s);
        return Result.success(upload);
    }
}
